/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.bridge.major;

import java.util.Collection;
import java.util.Collections;
import ru.jSkyRoom.interfaces.major.FormList;
import ru.jSkyRoom.interfaces.major.HeadPart;
import ru.jSkyRoom.interfaces.major.Texture;
import ru.jSkyRoom.interfaces.sub.JSkyModel;
import skyproc.FormID;
import skyproc.HDPT;
import skyproc.Model;

/**
 *
 * @author Rakev
 */
public class HeadPartBridge extends NamedMajorBridge<HDPT> implements HeadPart {

    public HeadPartBridge(HDPT adapting) {
        super(adapting);
    }

    @Override
    public JSkyModel getModel() {
        Model model = getRawObject().getModelData();
        return getBridgeFactory().createBridge(model);
    }

    @Override
    public Collection<HeadPart> getHeadParts() {
        Collection<FormID> ids = getRawObject().getHeadParts();
        Collection<HeadPart> parts = getFinderFactory().createHeadPartFinder().find(ids);
        return Collections.unmodifiableCollection(parts);
    }

    @Override
    public void addHeadPart(HeadPart headPart) {
        FormID id = headPart.getForm();
        getRawObject().addHeadPart(id);
    }

    @Override
    public void removeHeadPart(HeadPart headPart) {
        FormID id = headPart.getForm();
        getRawObject().removeHeadPart(id);
    }

    @Override
    public Texture getBaseTexture() {
        FormID id = getRawObject().getBaseTexture();
        return getFinderFactory().createTextureFinder().find(id);
    }

    @Override
    public void setBaseTexture(Texture texture) {
        FormID id = getIdProducer().produce(texture);
        getRawObject().setBaseTexture(id);
    }

    @Override
    public FormList getResourceList() {
        FormID id = getRawObject().getResourceList();
        return getFinderFactory().createFormListFinder().find(id);
    }
}
